package com.mxt.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.mxt.dao.UserDao;
import com.mxt.domain.User;
import com.mxt.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;


@Service
public class UserServiceImpl implements UserService {
    @Autowired
    private UserDao userDao;

    @Override
    public List<User> queryAll() {
        return userDao.queryAll();
    }
   /* @Override
    public PageInfo<User> queryAll(Integer cid, String keyword,Integer pageNumber, Integer pageSize) {
        //设置分页：设置后第一条执行的select语句，将会进行分页
        PageHelper.startPage(pageNumber, pageSize);

        //条件搜索：这次执行的select将会被分页
        List<User> userList = userDao.queryAll();

        //封装结果：由插件帮我们计算并封装分页结果
        return new PageInfo<>(userList, 5);
    }*/

    @Override
    public void save(User user) {
        userDao.save(user);
    }

    @Override
    public User findById(Integer id) {
        return userDao.findById(id);
    }

    @Override
    public void update(User user) {
        userDao.update(user);
    }

    @Override
    public void delete(Integer id) {
        userDao.delete(id);
    }
}
